/**
 * Project Name:SimonFramework
 * File Name:FailReason.java
 * Package Name:com.simon.framework.image.core.assist
 * Date:2016-5-19 下午3:52:42
 * Copyright (c) 2016, simon@cmonbaby.com All Rights Reserved.
 */
package com.cmonbaby.images.core.assist;

/**
 * <p>Author:      Simon
 * <p>QO:          8950764
 * <p>Email:       simon@cmonbaby.com
 * <p>WebSize:     https://www.cmonbaby.com
 * <p>Version:     1.0.0
 * <p>Date:        2020/12/29
 * <p>Description: 图片加载和显示失败的原因
 */
public class FailReason {

    private final FailType type;

    private final Throwable cause;

    public FailReason(FailType type, Throwable cause) {
        this.type = type;
        this.cause = cause;
    }

    /** @return {@linkplain FailType Fail type} */
    public FailType getType() {
        return type;
    }

    /** @return 抛出异常/错误,可以为<b>null</b> */
    public Throwable getCause() {
        return cause;
    }

    /** 加载图像失败而报出的类型 */
    public static enum FailType {
        /** 输入/输出流错误。可能是由于网络通信失败或错误而缓存图像文件系统。 */
        IO_ERROR,
        /**
         * Error while
         * {@linkplain android.graphics.BitmapFactory#decodeStream(java.io.InputStream, android.graphics.Rect, android.graphics.BitmapFactory.Options)
         * 解码图像位图}
         */
        DECODING_ERROR,
        /**
         * {@linkplain com.cmonbaby.images.core.ImageLoader#denyNetworkDownloads(boolean)
         * 错误网络下载},并磁盘缓存的缓存不是要求形式。
         */
        NETWORK_DENIED,
        /** 没有足够的内存来创建需要位图图像 */
        OUT_OF_MEMORY,
        /** 加载图片时发生未知错误 */
        UNKNOWN
    }

}

